/**
 * @param {string[]} words
 * @param {number[][]} queries
 * @return {number[]}
 */
var vowelStrings = function (words, queries) {
  let prefixSum = new Array(words.length + 1).fill(0)
  let res = []
  for (let i = 0; i < words.length; i++) {
    if (isVowelString(words[i])) {
      prefixSum[i + 1] = prefixSum[i] + 1
    } else {
      prefixSum[i + 1] = prefixSum[i]
    }
  }

  for(let i=0;i<queries.length;i++){
    res[i]= prefixSum[queries[i][1]+1]-prefixSum[queries[i][0]]
  }

  function isVowelString(str) {
    return isVowelChar(str[0]) && isVowelChar(str[str.length - 1])
  }

  function isVowelChar(ch) {
    return ['a', 'e', 'i', 'o', 'u'].some(item => item == ch)
  }
  return res
}

vowelStrings(
  ['aba', 'bcb', 'ece', 'aa', 'e'],
  [
    [0, 2],
    [1, 4],
    [1, 1],
  ]
)
